<!-- 搜索表单 -->
<template>
    <el-card shadow="never" >
      <el-form
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="search"
        @submit.native.prevent
      >
        <el-row :gutter="24">
          <el-col :md="6" :sm="24">
            <el-form-item label="关键字:" label-width="58px" >
              <el-input clearable v-model="where.keyword" placeholder="支持单据编号、客户名称模糊查询" />
            </el-form-item>
          </el-col>
          <el-col :md="5" :sm="24">
            <el-form-item label="币种:" label-width="72px">
              <el-select v-model="where.currencyId" clearable placeholder="请选择币种">
                <el-option v-for="item in hbDatas" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :md="5" :sm="24">
            <el-form-item label="单据类型:" label-width="72px">
              <el-select v-model="where.auitOrderType" clearable placeholder="请输入单据类型">
                <el-option v-for="(item, index) in statusEnums" :key="index" :label="item.Value" :value="item.Key" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :md="4" :sm="24" >
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                @click="search"
              >
                查询
              </el-button>
              <el-button @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    </template>
    
    <script>
      const DEFAULT_WHERE = {
        keyword:'',
        currencyId:'',
        status:'',
        createDate:'',
      };
      import { QueryRecBillTypeEnum } from '@/api/enummanger';
      import { QueryAllChildDictViewByCode } from '@/api/systemmanager/dictmanager';

      export default {
        name: 'RecreceipSearch',
        data() {
          return {
            // 表单数据
            where: { ...DEFAULT_WHERE },
            statusEnums:[],
            hbDatas:[],
          };
        },
        //初始化数据
        created(){
          this.queryCustomerDatas();
        },
        methods: {
    
          /* 搜索 */
          search() {
            let params = {
              pageindex: 1,
              conditions: [],
              orderBys: [{ sort: "createDate", order: 1, }],
            };

            //收入类型
            if(this.where.keyword){
              params.conditions.push({
                key:"orderNo,customerName",
                operator: 1,
                value: this.where.keyword,
              });
            }

             //收入类型
             if(this.where.currencyId){
              params.conditions.push({
                key:"currencyId",
                operator: 0,
                value: this.where.currencyId,
              });
            }

              //收入类型
              if(this.where.status){
              params.conditions.push({
                key:"status",
                operator: 0,
                value: this.where.status,
              });
            }

            this.$emit('search', params);
          },

          /*  重置 */
          reset() {
            this.where = { ...DEFAULT_WHERE };
            this.search();
          },
         
          /* 系统状态 */
          async queryCustomerDatas(){
            let sysEnums = await QueryRecBillTypeEnum();
            sysEnums.map(e=>{
              this.statusEnums.push({Key:e.Key,Value:e.Value});
            });

            QueryAllChildDictViewByCode(this.Constant.C_HB).then((data)=>{
              this.hbDatas = [];
              this.hbDatas = data;
            });
          },
        }
      };
    </script>
    